/*
'--------------------------------------
'Power By 方卡在线 @2010-2014 f02
'URL:http://www.fangka.net/
'EMail:admin@ifangka.com
'QQ:861118936
'版权所有 未经允许不得去除本版权信息
'--------------------------------------
*/

var isPost=0;
var f_Id=1
var picId=0
var picIdNow=0;
var ext_link,ext_img,ext_flash,ext_media;
var rUrl='';
var sysDebug=0;

$(document).ready(function(){
	bindReset();
});

//.bindReset
function bindReset(){
    $("a[target='get']").unbind("click").click(function() {
        ajax_get($(this).attr('div'),$(this).attr('href'));
		return false;
    });
    $("a[target='dialog']").unbind("click").click(function() {
        dialogOpen($(this).attr('href'),$(this).attr('width'));
		return false;
    });
    $("a[target='delete']").unbind("click").click(function() {
        ajax_delete($(this));
		return false;
    });
	$("form[target='ajax']").unbind("submit").submit(function() {
		ajax_post($(this));
		return false;
	});
	bindUpload();
}

//.get
function ajax_get(div,url){
	$('#'+div).html("<img src='Images/loading.gif' />");
	$.ajax({
		type: 'GET',
		url: url,
		dataType: 'text',
		cache: false,
		timeout: 30000,
		success: function(data, textStatus){
			$('#'+div).html(data);
			pageReset();
			$('body,html').animate({scrollTop:0},100);
			bindReset();
		},
		error: function(xhr){
			if(xhr.status==0){
				alert('数据提交超时，请重试！');
			}else{
				if(sysDebug==0){
					alert('数据提交出现错误，请与管理员联系！');
				}else{
					alert('数据提交出现错误！\n\nstatus:'+xhr.status+'\n\n'+xhr.responseText);
				}
			}
			xhr=null;
		}
	});
}

//.post
function ajax_post(obj){
	if(isPost==0){
		isPost=1;
		var postUrl=$(obj).attr('action');
		var alertStr=$(obj).attr('alertStr') || '';
		var confirmStr=$(obj).attr('confirmStr') || '';
		var showStr=$(obj).attr('showStr') || '';
		var hrefUrl=$(obj).attr('hrefUrl') || '';
		var refreshUrl=$(obj).attr('refreshUrl') || '';
		var refreshDiv=$(obj).attr('refreshDiv') || 'mainRight';
		var boxClose=$(obj).attr('boxClose') || '0';
		var SiteSet=$(obj).attr('SiteSet') || '0';
		var menuChange=$(obj).attr('menuChange') || '0';
		var postDataType=$(obj).attr('dataType') || 'json';
		var postTimeOut=$(obj).attr('timeOut') || 30000;
		var postDataTypes=postDataType;
		if(refreshDiv=='no'){
			refreshDiv='';
		}
		if(confirmStr!=''){
			if(!confirm(confirmStr)){
				return false;
			}
		}
		if($('#Enter').length>0){
			var submitButton=$('#Enter').val();
			$('#Enter').val('正在提交');
		}
		$.ajax({
			type: 'POST',
			url: $(obj).attr('action'),
			data: $(obj).serializeArray(),
			dataType: postDataTypes,
			cache: false,
			timeout: postTimeOut,
			success: function(data, textStatus){
				isPost=0;
				if(data==null||data==''){
					alert('未获得返回值，请检查！');
				}else{
					if(postDataType=='json'){
						if(data.statusCode=='200'){
							if(alertStr!=''){
								alert(alertStr);
							}
							if(showStr!=''){
								$('#msgContent').html(showStr);
								$('#msgBox').show();
								setTimeout('hiddenMsg()',4000);
							}
							if(hrefUrl!=''){
								location.href=hrefUrl;
							}
							if(refreshUrl!=''){
								ajax_get(refreshDiv,refreshUrl);
							}
							if(boxClose=='1'){
								dialogClose();
							}
							if(menuChange=='1'){
								ajax_get('nav','Get.asp?Type=2');
								ajax_get('mainLeft','Get.asp?Type=6');
							}
							if(SiteSet=='1'){
								ajax_get('mainLeft','Get.asp?Type=3');
							}
						}else{
							alert(data.errorStr);
						}
					}else if(postDataType=='text'){
						if(alertStr=='data'){
							alert(data);
						}else if(alertStr!=''){
							alert(alertStr);
						}
						if(hrefUrl!=''){
							location.href=hrefUrl;
						}
						if(showStr!=''){
							$('#msgContent').val(showStr);
							$('#msgBox').show();
							setTimeout('hiddenMsg()',3000);
						}
						if(refreshDiv!=''){
							$('#'+refreshDiv).html(data);
							pageReset();
							bindReset();
						}
					}
				}
				if($('#Enter').length>0){
					$('#Enter').val(submitButton);
				}
				$('body,html').animate({scrollTop:0},100);
			},
			error: function(xhr){
				isPost=0;
				if(xhr.status==0){
					alert('数据提交超时，请重试！');
				}else{
					if(sysDebug==0){
						alert('数据提交出现错误，请与管理员联系！');
					}else{
						alert('数据提交出现错误！\n\nstatus:'+xhr.status+'\n\n'+xhr.responseText);
					}
				}
				if($('#Enter').length>0){
					$('#Enter').val(submitButton);
				}
				xhr=null;
			}
		});
	}else{
		//alert("请勿重复提交！");
	}
}

//.delete
function ajax_delete(obj){
	var url=$(obj).attr('href');
	var confirmStr=$(obj).attr('confirmStr') || '您确定要删除？此操作不可逆！';
	var alertStr=$(obj).attr('alertStr') || '';
	var showStr=$(obj).attr('showStr') || '';
	var refreshUrl=$(obj).attr('refreshUrl') || '';
	var refreshDiv=$(obj).attr('refreshDiv') || 'mainRight';
	if(confirm(confirmStr)){
		$.get(url,
			function(data){
				if(data=='ok'){
					if(alertStr!=''){
						alert(alertStr);
					}
					if(showStr!=''){
						$('#msgContent').html(showStr);
						$('#msgBox').show();
						setTimeout('hiddenMsg()',4000);
					}
					if(refreshUrl!=''){
						ajax_get(refreshDiv,refreshUrl);
					}
				}else{
					alert(data);
				}
			}
		);
		return false;
	}else{
		return false;
	}
}

//.dialogOpen
function dialogOpen(url,d_width){
	$('#dialog').html("<a href='javascript:void(0);' title='点此关闭' onclick='dialogClose();'><img src='Images/dialog_loading.gif' /></a>");
	$('#dialog').width("200px");
	$('#dialog').css("padding-top","100px");;
	$("#dialogAlpha").height($(document).height());
	$("#dialogAlpha").width($(document).width());
	$('#dialogBox').show();
	$('#dialogAlpha').show();
	var bottom_width=d_width-20;
	$.ajax({
		type: 'GET',
		url: url,
		dataType: 'text',
		cache: false,
		timeout: 30000,
		success: function(data, textStatus){
			$('#dialog').html(data);
			$('#dialog').width(d_width+"px");
			$('#dialog').css("padding-top","20px");;
			$('#dialog #bottom').css("width",bottom_width+"px");
			$('.help').append('&nbsp;&nbsp;<img src="Images/help.jpg" />');
			$('.help').simpletooltip();
			$('.show').simpletooltip();
			if($('.xheditor').length>0){
				$('.xheditor').xheditor({upLinkUrl:'Upload.asp?immediate=1',upLinkExt:ext_link,upImgUrl:'Upload.asp?immediate=1',upImgExt:ext_img,upFlashUrl:'Upload.asp?immediate=1',upFlashExt:ext_flash,upMediaUrl:'Upload.asp?immediate=1',upMediaExt:ext_media});
			}
			if($('.triState').length>0){
				$('ul.triState','').tristate({
					heading: 'span.title'
				});
			}
			bindReset();
			pageReset();
			$('body,html').animate({scrollTop:0},100);
		},
		error: function(xhr){
			if(xhr.status==0){
				alert('数据提交超时，请重试！');
			}else{
				if(sysDebug==0){
					alert('数据提交出现错误，请与管理员联系！');
				}else{
					alert('数据提交出现错误！\n\nstatus:'+xhr.status+'\n\n'+xhr.responseText);
				}
			}
			dialogClose();
			xhr=null;
		}
	});
}

//.dialogClose
function dialogClose(){
	$('.ueditor').each(function(){
		if($(this).attr('id'))
			UE.getEditor($(this).attr('id')).destroy();
	});  
	$('.oc_upload').remove();
	$('#dialogBox').hide();
	$('#dialogAlpha').hide();
	$('body,html').animate({scrollTop:0},100);
}

//.closeMsgBox
function hiddenMsg(){
	$("#msgBox").hide();
}

//.JMailTest
function JMailTest(){
	var pUlr="JMail.asp?Type=3&Option=";
	pUlr+="EMail_Address:"+$('#EMail_Address').val()+"|;|";
	pUlr+="EMail_Accouns:"+$('#EMail_Accouns').val()+"|;|";
	pUlr+="EMail_Pwd:"+$('#EMail_Pwd').val()+"|;|";
	pUlr+="EMail_Smtp:"+$('#EMail_Smtp').val()+"|;|";
	pUlr+="EMail_To:"+$('#EMail_To').val()+"|;|";
	$.get(pUlr,
		function(data){
			alert(data);
		}
	);
}

//.checkAll
function CheckAll(form) {
	for (var i = 0; i < form.elements.length; i++) {
		var e = form.elements[i];
		if (e.name != 'chkall') 
			e.checked = form.chkall.checked;
	}
}

//.bnav
function bnav(navid){
	$('.t').hide();
	$('#t'+navid).show();
	$('.bnr').removeClass('check');
	$('#s'+navid).addClass('check');
}

//.ChangeSelect
function ChangeSelect(Urls,SId){
	$.get(Urls,
		function(data){
			if(data!=""){
				BuildSel(data,document.getElementById(SId));
			}
			return true;
		}
	);
}

//.BuildSel
function BuildSel(Str,Sel){
	var Arrstr = new Array();
	Arrstr = Str.split(",,,,,");
	if(Str!=""){
		Sel.options.length=0;
		var arrst;
		for(var i=0;i<Arrstr.length;i++){
			if(Arrstr[i]!=""){
				Arrst=Arrstr[i].split("|||||");
				Sel.options[Sel.options.length]=new Option(Arrst[1],Arrst[0]);
			}
		}
	}
}

//.GetFocusLabel
function GetFocusLabel(fId,fFocus,fWidth,fHeight){
	var strLabel='&lt;script type=&quot;text/javascript&quot; src=&quot;{$SiteDir$}Plugin/FlashFocus/'+fFocus+'/focus.asp?Type=1&Id='+fId+'&Width='+fWidth+'&Height='+fHeight+'&quot;&gt;&lt;/script&gt;';
	strLabel='<p><input type="text" class="input" size="100" value="'+strLabel+'" />&nbsp;调用代码</p>';
	$('#BuildResult').html(strLabel);
}

//.AddField
function AddField(){
	var f_Name,f_Remark,f_Label,f_Help,f_Type,f_Option
	var o_arr=new Array();
	f_Name=$('#Field_Name').val();
	f_Remark=$('#Field_Remark').val();
	f_Label=$('#Field_Label').val();
	f_Help=$('#Field_Help').val();
	f_Type=$('#Field_Type').val();
	f_Option=$('#Field_Option').val();//.replace(/\n/ig,'|-|');
	if(f_Name==''){
		alert('请输入字段名称！');
		return false;
	}
	if(f_Remark==''){
		alert('请输入字段备注！');
		return false;
	}
	if(f_Label==''){
		alert('请输入字段标识！');
		return false;
	}
	if(f_Help==''){
		alert('请输入字段帮助！');
		return false;
	}
	if(f_Type==''){
		alert('请输入字段类型！');
		return false;
	}
	if(f_Option==''&&f_Type==3){
		alert('请输入字段选项！');
		return false;
	}else if(f_Type==3){
		o_arr=f_Option.split(/\n/ig);
		for(var z=0;z<o_arr.length;z++){
			if(o_arr[z].indexOf('||')==-1){
				alert('选项包括选项值和显示字符两项，用||隔开，例如：1||选项1');
				return false;
			}
		}
	}
	
	AddField_Show(f_Name,f_Remark,f_Label,f_Help,f_Type,f_Option);
	
	$('#Field_Name').val('');
	$('#Field_Remark').val('');
	$('#Field_Label').val('');
	$('#Field_Help').val('');
	$('#Field_Option').val('');
}

//.AddField_Show
function AddField_Show(fName,fRemark,fLabel,fHelp,fType,fOption){
	var code='';
	var fTypeName;
	f_Id++;
	switch(fType){
		case '0':
			fTypeName="文本框";
			break;
		case '1':
			fTypeName="编辑器框";
			break;
		case '2':
			fTypeName="上传框";
			break;
		case '3':
			fTypeName="下拉框";
			break;
	}
	code+='<div id="Field_'+f_Id+'" class="field_div">';
	code+='<table width="90%" border="1" bordercolor="#CCCCCC" align="center" cellpadding="0" cellspacing="0">';
	code+='<tr>';
	code+='<td height="30" colspan="4" class="field_title">'+fTypeName+'字段&nbsp;&nbsp;<a href="javascript:void(0);" onclick="if(confirm(\'确定删除？\')){$(\'#Field_'+f_Id+'\').remove();}else{return false;}">[删除]</a></td>';
	code+='</tr>';
	code+='<tr>';
	code+='<td width="10%" height="30" align="right">名称：</td>';
	code+='<td>&nbsp;<input name="Fk_Model_Field" type="hidden" id="Fk_Model_Field" value="Field_Name:" /><input name="Fk_Model_Field" type="text" class="input" id="Fk_Model_Field" size="40" value="'+fName+'" /></td>';
	code+='<td width="10%" align="right">备注：</td>';
	code+='<td>&nbsp;<input name="Fk_Model_Field" type="hidden" id="Fk_Model_Field" value="|;|Field_Remark:" /><input name="Fk_Model_Field" type="text" class="input" id="Fk_Model_Field" size="40" value="'+fRemark+'" /></td>';
	code+='</tr>';
 	code+='<tr>';
	code+='<td height="30" align="right">字段标识：</td>';
	code+='<td>&nbsp;<input name="Fk_Model_Field" type="hidden" id="Fk_Model_Field" value="|;|Field_Label:" /><input name="Fk_Model_Field" type="text" class="input" id="Fk_Model_Field" size="40" value="'+fLabel+'" /></td>';
	code+='<td align="right">帮助语句：</td>';
	code+='<td>&nbsp;<input name="Fk_Model_Field" type="hidden" id="Fk_Model_Field" value="|;|Field_Help:" /><input name="Fk_Model_Field" type="text" class="input" id="Fk_Model_Field" size="40" value="'+fHelp+'" /></td>';
	code+='</tr>';
	if(fType==3){
		code+='<tr>';
		code+='<td height="30" align="right">选项：</td>';
		code+='<td colspan="3">&nbsp;<input name="Fk_Model_Field" type="hidden" id="Fk_Model_Field" value="|;|Field_Type:'+fType+'|;|Field_Option:" /><textarea name="Fk_Model_Field" class="textarea" cols="60" rows="5" id="Fk_Model_Field">'+fOption.replace(/\|\-\|/ig,"\n")+'</textarea><input name="Fk_Model_Field" type="hidden" id="Fk_Model_Field" value="|;||FieldList|" /></td>';
		code+='</tr>';
		code+='</table>';
	}else{
		code+='</table>';
		code+='<input name="Fk_Model_Field" type="hidden" id="Fk_Model_Field" value="|;|Field_Type:'+fType+'|;|Field_Option:|;||FieldList|" />';
	}
	code+='</div>';
	$('#FieldList').before(code);
	$("#dialogAlpha").height($(document).height());
}

//.AddGBookField
function AddGBookField(){
	var f_Name,f_Label,f_StrMin,f_StrMax,f_ListShow
	f_Name=$('#Field_Name').val();
	f_Label=$('#Field_Label').val();
	f_StrMin=$('#Field_StrMin').val();
	f_StrMax=$('#Field_StrMax').val();
	f_ListShow=$('#Field_ListShow').attr('checked');
	if(f_ListShow){
		f_ListShow=1;
	}else{
		f_ListShow=0;
	}
	if(f_Name==''){
		alert('请输入字段名称！');
		return false;
	}
	if(f_Label==''){
		alert('请输入字段标识！');
		return false;
	}
	if(f_StrMin==''){
		alert('请输入留言最短字数！');
		return false;
	}
	if(f_StrMax==''){
		alert('请输入留言最多字数！');
		return false;
	}
	if(isNaN(f_StrMin)){
		alert('留言最短字数必须为数字！');
		return false;
	}
	if(isNaN(f_StrMax)){
		alert('留言最多字数必须为数字！');
		return false;
	}
	if(f_Label.substr(0,6)!='GBook_'){
		alert('标识必须GBook_开头！');
		return false;
	}
	
	AddGBookField_Show(f_Name,f_Label,f_StrMin,f_StrMax,f_ListShow,1);
	
	$('#Field_Name').val('');
	$('#Field_Label').val('GBook_');
	$('#Field_StrMin').val('1');
	$('#Field_StrMax').val('50');
	$('#Field_ListShow').attr('checked','');
}

//.AddGBookField_Show
function AddGBookField_Show(fName,fLabel,fStrMin,fStrMax,fListShow,fDelete){
	var code='';
	f_Id++;
	code+='<div id="Field_'+f_Id+'" class="field_div">';
	code+='<table width="90%" border="1" bordercolor="#CCCCCC" align="center" cellpadding="0" cellspacing="0">';
	code+='<tr>';
	code+='<td height="30" colspan="4" class="field_title">留言字段';
	if(fDelete==1){
		code+='&nbsp;&nbsp;<a href="javascript:void(0);" onclick="if(confirm(\'确定删除？\')){$(\'#Field_'+f_Id+'\').remove();}else{return false;}">[删除]</a>';
	}else{
		code+='&nbsp;&nbsp;[标题字段作为唯一判断必须存在，前台可以显示为其他名称]';
	}
	code+='</td>';
	code+='</tr>';
	code+='<tr>';
	code+='<td width="10%" height="30" align="right">名称：</td>';
	code+='<td>&nbsp;<input name="Fk_Model_Field" type="hidden" id="Fk_Model_Field" value="Field_Name:" /><input name="Fk_Model_Field" type="text" class="input" id="Fk_Model_Field" size="40" value="'+fName+'" /></td>';
	code+='<td width="10%" align="right">字段标识：</td>';
	code+='<td>&nbsp;<input name="Fk_Model_Field" type="hidden" id="Fk_Model_Field" value="|;|Field_Label:" /><input name="Fk_Model_Field" type="text" class="input" id="Fk_Model_Field" size="40" value="'+fLabel+'" /></td>';
	code+='</tr>';
 	code+='<tr>';
	code+='<td height="30" align="right">最短字数：</td>';
	code+='<td>&nbsp;<input name="Fk_Model_Field" type="hidden" id="Fk_Model_Field" value="|;|Field_StrMin:" /><input name="Fk_Model_Field" type="text" class="input" id="Fk_Model_Field" size="40" value="'+fStrMin+'" /></td>';
	code+='<td align="right">最长字数：</td>';
	code+='<td>&nbsp;<input name="Fk_Model_Field" type="hidden" id="Fk_Model_Field" value="|;|Field_StrMax:" /><input name="Fk_Model_Field" type="text" class="input" id="Fk_Model_Field" size="40" value="'+fStrMax+'" /></td>';
	code+='</tr>';
	code+='<td width="10%" height="30" align="right">列表显示：</td>';
	code+='<td colspan="3">&nbsp;<input name="Fk_Model_Field" type="hidden" id="Fk_Model_Field" value="|;|Field_ListShow:" /><input type="checkbox" name="Fk_Model_Field" class="input" id="Fk_Model_Field" value="1"';
	if(fListShow==1){
		code+=' checked="checked"';
	}
	code+=' /><input name="Fk_Model_Field" type="hidden" id="Fk_Model_Field" value="|;||FieldList|" /></td>';
	code+='</tr>';
	code+='</div>';
	$('#FieldList').before(code);
	$("#dialogAlpha").height($(document).height());
}

//.AddFocus
function AddFocus(){
	var f_Title,f_Url,f_Pic
	f_Title=$('#Focus_Title').val();
	f_Url=$('#Focus_Url').val();
	f_Pic=$('#Focus_Pic').val();
	if(f_Title==''){
		alert('请输入标题！');
		return false;
	}
	if(f_Url==''){
		alert('请输入链接！');
		return false;
	}
	if(f_Pic==''){
		alert('请输入图片链接或上传图片！');
		return false;
	}
	
	AddFocus_Show(f_Title,f_Url,f_Pic);
	
	$('#Focus_Title').val('');
	$('#Focus_Url').val('');
	$('#Focus_Pic').val('');
	bindUpload();
}

//.AddFocus_Show
function AddFocus_Show(fTitle,fUrl,fPic){
	var code='';
	f_Id++;
	code+='<div id="Focus_'+f_Id+'" class="field_div">';
	code+='<table width="90%" border="1" bordercolor="#CCCCCC" align="center" cellpadding="0" cellspacing="0">';
	code+='<tr>';
	code+='<td height="30" colspan="4" class="field_title">轮换条目';
	code+='&nbsp;&nbsp;<a href="javascript:void(0);" onclick="if(confirm(\'确定删除？\')){$(\'#Focus_'+f_Id+'\').remove();}else{return false;}">[删除]</a>';
	code+='</td>';
	code+='</tr>';
	code+='<tr>';
	code+='<td width="12%" height="30" align="right">标题：</td>';
	code+='<td>&nbsp;<input name="Fk_Focus_Content" type="hidden" id="Fk_Focus_Content" value="Focus_Title:" /><input name="Fk_Focus_Content" type="text" class="input" id="Fk_Focus_Content" size="20" value="'+fTitle+'" /></td>';
	code+='</tr>';
	code+='<tr>';
	code+='<td width="12%" height="30" align="right">链接：</td>';
	code+='<td>&nbsp;<input name="Fk_Focus_Content" type="hidden" id="Fk_Focus_Content" value="|;|Focus_Url:" /><input name="Fk_Focus_Content" type="text" class="input" id="Fk_Focus_Content" size="40" value="'+fUrl+'" /></td>';
	code+='</tr>';
	code+='<tr>';
	code+='<td width="12%" height="30" align="right">图片：</td>';
	code+='<td>&nbsp;<input name="Fk_Focus_Content" type="hidden" id="Fk_Focus_Content" value="|;|Focus_Pic:" /><input name="Fk_Focus_Content" type="text" class="input" id="Focus_Pic_'+f_Id+'" size="40" value="'+fPic+'" />';
	code+=' <input type="button" class="picList_btn btnUpload" name="btnFocusPic" id="btnFocusPic" value="上传轮换图片" callback="2" inputId="Focus_Pic_'+f_Id+'" fileAction="Upload.asp?immediate=3" />';
	code+='<input name="Fk_Focus_Content" type="hidden" id="Fk_Focus_Content" value="|;||FocusList|" /></td>';
	code+='</tr>';
	code+='</div>';
	$('#FocusList').before(code);
	$("#dialogAlpha").height($(document).height());
}

//.AddVote
function AddVote(){
	var f_Record,f_Ticket
	f_Record=$('#Vote_Record').val();
	f_Ticket=$('#Vote_Ticket').val();
	if(f_Record==''){
		alert('请输入投票项！');
		return false;
	}
	if(f_Ticket==''){
		alert('请输入票数！');
		return false;
	}

	AddVote_Show(f_Record,f_Ticket);
	
	$('#Vote_Record').val('');
	$('#Vote_Ticket').val('0');
}

//.AddVote_Show
function AddVote_Show(fRecord,fTicket){
	var code='';
	f_Id++;
	code+='<div id="Vote_'+f_Id+'" class="field_div">';
	code+='<table width="90%" border="1" bordercolor="#CCCCCC" align="center" cellpadding="0" cellspacing="0">';
	code+='<tr>';
	code+='<td height="30" colspan="4" class="field_title">投票项';
	code+='&nbsp;&nbsp;<a href="javascript:void(0);" onclick="if(confirm(\'确定删除？\')){$(\'#Vote_'+f_Id+'\').remove();}else{return false;}">[删除]</a>';
	code+='</td>';
	code+='</tr>';
	code+='<tr>';
	code+='<td height="30" width="10%" align="right">投票项：</td>';
	code+='<td width="40%">&nbsp;<input name="Fk_Vote_Content" type="hidden" id="Fk_Vote_Content" value="Vote_Record:" /><input name="Fk_Vote_Content" type="text" class="input" id="Fk_Vote_Content" value="'+fRecord+'" size="40" /></td>';
	code+='<td width="10%" align="right">投票数：</td>';
	code+='<td width="40%">&nbsp;<input name="Fk_Vote_Content" type="hidden" id="Fk_Vote_Content" value="|;|Vote_Ticket:" /><input name="Fk_Vote_Content" type="text" class="input" id="Fk_Vote_Content" value="'+fTicket+'" value="0" size="4" />';
	code+='<input name="Fk_Vote_Content" type="hidden" id="Fk_Vote_Content" value="|;||VoteList|" /></td>';
	code+='</tr>';
	code+='</div>';
	$('#VoteList').before(code);
	$("#dialogAlpha").height($(document).height());
}

//.bindUpload
function bindUpload(){
	var callBackType,callBackInput;
	var json_arr;
	$('.oc_upload').remove();
	$('.btnUpload').each(function(i){
		callBackType=$(this).attr('callback') || '0';
		callBackInput=$(this).attr('inputId') || '';
		$(this).upload({
			name: $(this).attr('fileInput') || 'filedata',
			action: $(this).attr('fileAction') || 'Upload.asp?immediate=2',
			enctype: 'multipart/form-data',
			params: {},
			callBackOption: {'type':callBackType,'input':callBackInput},
			autoSubmit: false,
			onSubmit: function() {				
			},
			onComplete: function(data,arrOption) {
				try{
					json_arr=eval("("+data+")");
				}catch(e){
					alert('文件上传失败！\n\nnumber:'+e.number+'\n\n'+data);
					$('.oc_upload').remove();
					bindUpload();
					return false;
				}
				switch(arrOption['type']){
					case '0':
						alert('0');
						break;
					case '1':
						uploadPicList(json_arr);
						break;
					case '2':
						uploadFiles(json_arr,arrOption['input']);
						break;
					default:
						alert('未找到上传返回类型！');
				}
				bindUpload();
			},
			onSelect: function() {}
		});
	});
}

//.uploadPicList
function uploadPicList(jsonArr){
	var isDefault=0;
	if(jsonArr.err!=''){
		alert(jsonArr.err);
	}else{
		if($(".picCheck").length==0){
			isDefault=1;
		}
		uploadPicList_Show(jsonArr.msg,'',isDefault);
		$('.show').simpletooltip();
		pageReset();
		bindUpload();
	}
}

//.uploadPicList_Show
function uploadPicList_Show(picStr,picAbout,picDefault){
	var code;
	var picArr=picStr.split("||");
	code='<div id="p'+picId+'" class="picList'
	if(picDefault==1){
		code=code+' picCheck';
		picIdNow=picId;
		$('#Fk_View_Pic').val(picArr[0]);
		$('#Fk_View_PicBig').val(picArr[1]);
	}
	code=code+'">';
	code=code+'<img src="'+picArr[0]+'" width="60" height="60" class="show" title="<img src='+picArr[0]+' style=\'max-width:700px;max-height:700px;\' />" onclick="picList_check('+picId+',\''+picArr[0]+'\',\''+picArr[1]+'\')" /><br />';
	code=code+'<input name="Fk_View_PicList" type="hidden" id="Fk_View_PicList" value="'+picArr[0]+'||'+picArr[1]+'||" />';
	code=code+'<input name="Fk_View_PicList" type="text" class="input" id="Fk_View_PicList" value="'+picAbout+'" style="width:60px;" />';
	code=code+'<input name="Fk_View_PicList" type="hidden" id="Fk_View_PicList" value="|-_-|" /><br />';
	code=code+'<a href="javascript:void(0);" onclick="picList_remove('+picId+');" title="删除">删除</a>';
	code=code+'</div>';
	++picId;
	$("#viewPicList").before(code);
}

//.uploadFiles
function uploadFiles(jsonArr,sId){
	if(jsonArr.err!=''){
		alert(jsonArr.err);
	}else{
		$('#'+sId).val(jsonArr.msg);
	}
}

//.picList_check
function picList_check(sId,sPic,sPicBig){
	$('#Fk_View_Pic').val(sPic);
	$('#Fk_View_PicBig').val(sPicBig);
	$('.picList').removeClass('picCheck');
	$('#p'+sId).addClass('picCheck');
	picIdNow=sId;
}

//.picList_remove
function picList_remove(sId){
	if(picIdNow!=sId){
		$('#p'+sId).remove();
	}else{
		$('#p'+sId).remove();
		$('#Fk_View_Pic').val('');
		$('#Fk_View_PicBig').val('');
	}
	bindUpload();
}

//.CloseHideLink
function CloseHideLink(){
	$.get('HideLink.asp?Type=3',
		function(data){
			location.href='Index.asp';
		}
	);
}

//.OpenHideLink
function OpenHideLink(){
	$.get('HideLink.asp?Type=4',
		function(data){
			location.href='Index.asp';
		}
	);
}
